#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main(){
	int id=fork();
	if(id == 0) {  //子进程
        int cnt = 5;
        while(cnt--) {
            printf("子进程, pid:%d, ppid:%d, cnt:%d\n", getpid(), getppid(), cnt);
            sleep(1);
        }
        exit(1);
  }
     else {  //父进程
        sleep(10);
        int status = 0;
        pid_t ret = wait(NULL);
		printf("exit code:%d\n",status);
	 }
	 return 0;
  }
